
package com.insigma.business.qrcode.job.service.impl;



import com.insigma.business.qrcode.common.service.SequenceGenerator;
import com.insigma.business.qrcode.common.util.BizCheckUtil;
import com.insigma.business.qrcode.job.dao.JobCandidateResumeDao;
import com.insigma.business.qrcode.job.dto.search.JobCandidateResumeBSearcher;
import com.insigma.business.qrcode.job.entity.JobCandidateResumeDO;
import com.insigma.business.qrcode.job.service.JobCandidateResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.insigma.business.qrcode.soldier.dto.SequenceNameConstant;
import java.util.List;
import com.insigma.business.qrcode.job.dto.JobResumeDetailBO;

@Service("jobCandidateResumeService")
public class JobCandidateResumeServiceImpl implements JobCandidateResumeService {

    @Autowired(required = false)
    private JobCandidateResumeDao jobCandidateResumeDao;
    @Autowired(required = false)
    private SequenceGenerator sequenceGenerator;

    
    @Override
    public List<JobCandidateResumeDO> search(final JobCandidateResumeBSearcher jobCandidateResumeBSearcher) {
        return jobCandidateResumeDao.search(jobCandidateResumeBSearcher);
    }
   
    @Override
    public JobCandidateResumeDO get(final String id){
        return jobCandidateResumeDao.get(id);
    }

    
    @Override
    public Integer insert(final JobCandidateResumeDO jobCandidateResumeDO){
        jobCandidateResumeDO.setId(sequenceGenerator.genKey(SequenceNameConstant.JOB_CANDIDATE_RESUME_ID));
        return jobCandidateResumeDao.insert(jobCandidateResumeDO);
    }

    
    @Override
    public Integer update(final JobCandidateResumeDO jobCandidateResumeDO){
        return jobCandidateResumeDao.update(jobCandidateResumeDO);
    }

    
    @Override
    public Integer delete(final String id, final String modifierType, final String modifierId){
        return jobCandidateResumeDao.delete(id,modifierType,modifierId);
    }

    @Override
    public List<JobResumeDetailBO> searchResumeOfPosition(JobCandidateResumeBSearcher searcher) {
        return jobCandidateResumeDao.searchResumeOfCompanyAndPosition(searcher);
    }

    @Override
    public JobCandidateResumeDO getByCandidateId(String candidateId) {
        return jobCandidateResumeDao.getByCandidateId(candidateId);
    }

    @Override
    public void checkResumeIsComplete(String candidateId) {
        JobCandidateResumeDO byCandidateId = jobCandidateResumeDao.getByCandidateId(candidateId);
        BizCheckUtil.checkNotNull(byCandidateId, "简历不存在");
        BizCheckUtil.checkNotBlank(byCandidateId.getName(), "请完善简历，缺少姓名");
        BizCheckUtil.checkNotBlank(byCandidateId.getMobile(), "请完善简历，缺少联系方式");
        BizCheckUtil.checkNotBlank(byCandidateId.getWorkExperience(), "请完善工作经历");
    }

    @Override
    public Integer count() {
        Integer count = jobCandidateResumeDao.count();
        if (count == null) {
            return 0;
        }
        return count;
    }


}
